package com.psy.price.recorder.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

public class PropertiesConfigReader {


	private static PropertiesConfigReader instance = null;

	private TextBookSearchConfig config = new TextBookSearchConfig();


	private PropertiesConfigReader() {

	    Properties prop = new Properties();
	    try {
	        prop.load(new FileInputStream(new File("config/TextbookSearch.properties")));
	        config.setAccessKeyId(prop.getProperty("accessKeyId"));
	        config.setSecretKey(prop.getProperty("secretKey"));
	        config.setAppID(prop.getProperty("AppID"));
	        // this.connInfo = prop.getProperty("ConnInfo");
	        config.setProxyHost(prop.getProperty("ProxyHost"));
	        config.setProxyPort(Integer.valueOf(prop.getProperty("ProxyPort")).intValue());
	    } catch (FileNotFoundException e1) {
	        e1.printStackTrace();
	    } catch (IOException e1) {
	        e1.printStackTrace();
	    }

	}

	public static synchronized PropertiesConfigReader getInstance() {
		if (instance == null) {
			instance = new PropertiesConfigReader();
		}
		return instance;
	}

	public TextBookSearchConfig getTextBookSearchConfig() {
		return config;
	}


	public static void main(String[] args) {
		TextBookSearchConfig config = PropertiesConfigReader.getInstance().getTextBookSearchConfig();

		System.out.println(config);
	}

}
